
public interface Command {
    public void run();
}

class ViewBooksCommand implements Command {
    private Library library;
    private Menu menu;

    ViewBooksCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run(){
        library.printListOfBooks();
    }
}

class ViewMoviesCommand implements Command {
    private Library library;
    private Menu menu;

    ViewMoviesCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run(){
        System.out.println();
        System.out.println("Movie\tYear\tDirector\tRating");
        library.printListOfMovies();
    }
}

class ReserveBookCommand implements Command {
    private Library library;
    private Menu menu;

    ReserveBookCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run(){
        if(library.isUserActive()) {
            String target = menu.queryUser("Please enter the title of the book.");
            library.attemptToReserve(target);
        }
        else
            System.out.println("You must log in for this function!");
    }
}

class CheckMembershipCommand implements Command {
    private Library library;
    private Menu menu;

    CheckMembershipCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run(){
        if(library.isUserActive())
            library.printActiveUserDetails();
        else
            menu.printSeeLibrarian();
    }
}

class LoginCommand implements Command {
    private Library library;
    private Menu menu;

    LoginCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run() {
        String username = menu.queryUser("Please enter your username.");
        String password = menu.queryUser("Please enter your password.");
        library.attemptLogin(username,password);
    }
}


class QuitCommand implements Command {
    private Library library;
    private Menu menu;

    QuitCommand(Library library, Menu menu) {
        this.library = library;
        this.menu = menu;
    }

    @Override
    public void run() {
        System.out.println("Quitting!");
        System.exit(0);
    }
}


